#include "StdAfx.h"
#include "GameStateLogo.h"
#include "cSound.h"
extern int jumpPos;
extern bool isJump;
extern bool sound;
extern HWND hWnd;


CGameStateLogo::CGameStateLogo(void)
{
}

CGameStateLogo::~CGameStateLogo(void)
{
}
CGameStateLogo::CGameStateLogo(CGameMain *pGameMain)
{
	intro.push_back(new Bitmap(L"res\\intro.jpg"));
	intro.push_back(new Bitmap(L"res\\MenuBackground.png"));
	intro.push_back(new Bitmap(L"res\\QeenCity.png"));
	intro.push_back(new Bitmap(L"res\\option.jpg"));
	intro.push_back(new Bitmap(L"res\\SoundOff.jpg"));

	chosen				= new Bitmap(L"res\\chosen.png");
	pbmSprite			= new CMySprite(L"res\\newgame.png");

	// Get rect of png
	pbmSprite->GetRect(-1,-1);				
	// Set the position of character
	pbmSprite->RenderPosition(123,280);		
	pGM = pGameMain;
	GameStateID = STATE_LOGO;
	introID = 0;
	chosenPos = 1;
}
void CGameStateLogo::MessageEnter(HDC* pDC){

}
void CGameStateLogo::MessageUpdate(int iKey){

	if ((iKey & RIGHT)		== RIGHT && introID == 0) 
		chosenPos = 3;

	else if ((iKey & LEFT)	== LEFT && introID == 0) 
		chosenPos = 2;

	else if ((iKey & UP) == UP && introID == 0)
		chosenPos = 1;
	else if ((iKey & KEY_N) == KEY_N)
		pGM->SwitchState(STATE_LV1);

	else if ((iKey & ENTER) == ENTER) {
		if (introID == 2)
			sound = !sound;
		else if (introID == 1)
			introID = 2;
		introID = chosenPos;
		if (chosenPos == 3)
			pGM->isPlaying = false;
		pGM->KeyReleased(ENTER);
	}
	else if ((iKey & ESC) == ESC) {
		if (introID == 0)
			pGM->isPlaying = false;
		else if (introID == 2) 
			introID = 0;
		pGM->KeyReleased(ESC);
	}
	pbmSprite->NextFrame();
}
void CGameStateLogo::MessagePaint(HDC *pDC){
	Graphics g(*pDC);
	if (introID == 0 ) {
		g.DrawImage(intro[0],0,0);
		if (chosenPos == 1)
			g.DrawImage(chosen,145,5);
		else if (chosenPos == 2)
			g.DrawImage(chosen,100,37);
		else if (chosenPos == 3)
			g.DrawImage(chosen,255,37);
	}
	else if (introID == 1) {
		g.DrawImage(intro[1],0,0);
		pbmSprite->RenderAnimation(pDC);
	}
	else if (introID == 2) {
		g.DrawImage(intro[3],0,0);
		if (!sound)
			g.DrawImage(intro[4],258,205);
	}	
}
void CGameStateLogo::MessageExit() {
	intro.clear();
	delete pbmSprite;
}








